package com.ycz.controller;/*
 @author ycz
 @date 2021-09-24-14:40  
*/

import com.ycz.entity.TArticle;
import com.ycz.service.TArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class PageController {

    @Autowired
    private TArticleService articleService;


    @RequestMapping({"/","/index"})
    public String toIndex(){
        return "index";
    }

    @RequestMapping({"/blog","/blog/index"})
    public String toBlogIndex(Model model){
        List<TArticle> tArticleList=articleService.list(null);
        model.addAttribute("articleList",tArticleList);
        return "blog/index";
    }

    @RequestMapping("/blog/toSingle")
    public String toSingle(){
        System.out.println("进来了");
        return "blog/single";
    }


    @RequestMapping("/toLogin")
    public String toLogin(Model model){
        List<TArticle> tArticleList=articleService.list(null);
        model.addAttribute("articleList",tArticleList);
        return "blog/page-login";
    }

    @RequestMapping("/toAddBlog")
    public String toAddBlog(){
        return "blog/addBlog";
    }

}
